package com.zy.mobile.message.push.netty.heartbeat.util;

import io.netty.channel.ChannelHandlerContext;

import java.util.Date;
import java.util.concurrent.ConcurrentHashMap;

import com.zy.mobile.message.push.netty.heartbeat.protobuf.MessageProto;

public class ChannelHandlerContextMap {
	
	private static ConcurrentHashMap<Integer,ChannelHandlerContext> map = new ConcurrentHashMap<Integer,ChannelHandlerContext>();
	
	public static void put(Integer key,ChannelHandlerContext ctx){
		map.put(key, ctx);
	}
	
	public static ChannelHandlerContext get(Integer key){
		return map.get(key);
	}
	
	public static ConcurrentHashMap<Integer,ChannelHandlerContext> getMap(){
		return map;
	}
	
	public static void main(String[] args) {
		MessageProto.Message.Builder builder = MessageProto.Message.newBuilder();
		builder.setType(0);
		builder.setTimeStamp(new Date().getTime());
		builder.setOrderId(999);
		ChannelHandlerContextMap.map.get(2).writeAndFlush(builder.build());
	}
}
